package com.example.demo.service.impl;

import com.example.demo.dao.CourseChapterDao;
import com.example.demo.entity.CourseChapterBean;
import com.example.demo.service.CourseChapterService;
import com.example.demo.util.PageEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseChapterServiceImpl implements CourseChapterService {
    @Autowired
    private CourseChapterDao courseChapterDao;

    @Override
    public Integer add(CourseChapterBean courseChapterBean) {
        return courseChapterDao.add(courseChapterBean);
    }

    @Override
    public Integer update(CourseChapterBean courseChapterBean) {
        return courseChapterDao.update(courseChapterBean);
    }

    @Override
    public Integer delete(Integer id) {
        return courseChapterDao.delete(id);
    }

    @Override
    public CourseChapterBean one(Integer id) {
        return courseChapterDao.getOneById(id);
    }

    @Override
    public PageEntity list(Integer pageNo, Integer pageSize, String name, String sortOrder) {
        Integer count = courseChapterDao.count(name);
        List<CourseChapterBean> list = courseChapterDao.list(name, sortOrder);
        return new PageEntity<>(list, count);
    }
} 